package jsj.mynet;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class MyReceiveDemo {

	public static void main(String[] args) throws Exception {
		DatagramSocket ds = new DatagramSocket(10086);
		byte[] bys = new byte[1024];
		DatagramPacket dp = new DatagramPacket(bys, bys.length);
		
		while(true){
			ds.receive(dp);
			String ip = dp.getAddress().getHostAddress();
			int port = dp.getPort();
			String text = new String(dp.getData(), 0, dp.getLength());
			
			System.out.println(ip+":"+port+":"+text);
		}

	}

}
